#!/usr/bin/php -q
<?php
	
	include('config.php');

	$sql = mysql_query("SELECT * FROM vserver_daemon WHERE node = '".$node."'");
	while($row = mysql_fetch_assoc($sql)) {
		$task = $row['task'];

		$datei = fopen("run.sh","w+");
		fwrite($datei, $task);
		fclose($datei);


		$command = system("chmod 777 run.sh");
		$command = system("./run.sh");
		mysql_query("DELETE FROM vserver_daemon WHERE id = '".$row['id']."'");
		if($row['art'] == "start") {
			mysql_query("UPDATE vserver SET status = '1' WHERE veid = '".$row['veid']."'");
		}
		if($row['art'] == "stop") {
			mysql_query("UPDATE vserver SET status = '0' WHERE veid = '".$row['veid']."'");
		}
		if($row['art'] == "edit") {
			mysql_query("UPDATE vserver SET status = '1' WHERE veid = '".$row['veid']."'");
		}
		if($row['art'] == "backup") {
			mysql_query("UPDATE vserver SET status = '1' WHERE veid = '".$row['veid']."'");
		}

		mysql_query("INSERT INTO vserver_log SET veid = '".$row['veid']."', datum = '".time()."', task = 'vServer -".$row['art']."-'");
	}

?>